/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mscs.client.member.view;

import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Vector;
import mscs.data.pojo.Goods;
import mscs.data.pojo.Member;
import mscs.data.pojo.SaleRecord;

/**
 *
 * @author Administrator
 */
public class GiftTableModelFactory {
           public final static Vector<String> GIFT_MEMBER_COLUMN_NAMES = new Vector(Arrays.asList("用户编号","姓名","赠送原因"));
           public final static Vector<String> MEMBER_INFO_COLUMN_NAMES =new Vector(Arrays.asList("姓名","出生日期","性别","联系方式","积分总额"));
           public final static Vector<String> SALE_RECORD_COLUMN_NAMES = new Vector(Arrays.asList("商品标识","描述","数量"));
           public final static Vector<String> GIFT_TO_BE_SELECTED_COLUMN_NAMES = new Vector(Arrays.asList("赠品编号","描述","数量"));
           
           public static Vector<Vector<String>> toGiftMemerData(List<Member> memberList, List<Integer> reasonList){
               Vector<Vector<String>> newVector = new Vector<Vector<String>>();
               for(int i=0; i<memberList.size(); i++){
                   newVector.add(GiftMembertoStringArray(memberList.get(i), reasonList.get(i)));
               }
               return newVector;
           }
           private static Vector<String> GiftMembertoStringArray(Member member, int reason){
               Vector<String> newList = new Vector<String>();
               newList.add(member.getId());
               newList.add(member.getName());
               switch(reason){
                   case 0: newList.add("生日");break;
                   default: newList.add("积分突破"+reason);break;
               }
               return newList;
           }
           
           public static Vector<Vector<String>> toMemberInfoData(Member member){
               Vector<Vector<String>> newVector = new Vector<Vector<String>>();
               newVector.add(MemberInfotoStringArray(member));
               return newVector;
           }
           private static Vector<String> MemberInfotoStringArray(Member member){
               Vector<String> newList = new Vector<String>();
               SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
               newList.add(member.getName());
               newList.add(sdf.format(member.getBirthday()));
               newList.add(member.genderToString());
               newList.add(member.getContact());
               newList.add(String.valueOf(member.getTotalPoints()));
               return newList;
           }
           
           public static Vector<Vector<String>> toSaleRecordData(List<SaleRecord> recordList){
               Vector<Vector<String>> newVector = new Vector<Vector<String>>();
               for(SaleRecord record: recordList){
                   for(Goods goods:record.getGoodsList()){
                       newVector.add(GoodsToStringArray(goods));
                   }
               }
               return newVector;
           }
           private static Vector<String> GoodsToStringArray(Goods goods){
               Vector<String> newList = new Vector<String>();
               newList.add(goods.getId());
               newList.add(goods.getDesc());
               newList.add(String.valueOf(goods.getNum()));
               return newList;
           }
           
           public static Vector<Vector<String>> toGiftTobeSelectedData(List<Goods> goodsList){
               Vector<Vector<String>> newVector = new Vector<Vector<String>>();
               for(Goods gift: goodsList){
                   newVector.add(GiftToBeSelectedtoStringArray(gift));
               }
               return newVector;
           }
           private static Vector<String> GiftToBeSelectedtoStringArray(Goods gift){
               Vector<String> newList = new Vector<String>();
               newList.add(gift.getId());
               newList.add(gift.getDesc());
               newList.add(String.valueOf(gift.getNum()));
               return newList;
           }
           
           
           
           
}
